package routers

import (
	"github.com/gin-gonic/gin"
	admin "go_batch_create_orders/admin/controller"
	"go_batch_create_orders/middleware"
)

func AdminRouter(engine *gin.Engine) *gin.Engine {
	//配置路由等策略
	group := engine.Group("/admin", middleware.AdminJwtTokenMiddleware(), middleware.LoggerToFile())
	{
		orderGroup := group.Group("order")
		{
			orderGroup.POST("/batch_order", admin.GetOrderList)
			orderGroup.POST("/add_order", admin.AddOrder)
		}

		userGroup := group.Group("user")
		{
			userGroup.POST("/add_user", admin.AddUser)
			userGroup.GET("/del_user", admin.DeleteUser)
			userGroup.POST("/update_user", admin.UpdateUser)
			userGroup.GET("/get_token", admin.GetToken)
			userGroup.POST("/login", admin.Login)
			userGroup.GET("/test", admin.Test)
		}
		modelGroup := group.Group("model")
		{
			modelGroup.POST("/add", admin.AddModel)
			modelGroup.GET("/del", admin.DeleteModel)
			modelGroup.POST("/update", admin.UpdateModel)
			modelGroup.GET("/list", admin.GetModelList)
		}
		specCategoryGroup := group.Group("spec_category")
		{
			specCategoryGroup.GET("/add", admin.AddCategoryBefore)
			specCategoryGroup.POST("/add", admin.AddCategory)
			specCategoryGroup.GET("/del", admin.DeleteCategory)
			specCategoryGroup.GET("/update", admin.GetCategoryInfo)
			specCategoryGroup.POST("/update", admin.UpdateCategory)
			specCategoryGroup.GET("/list", admin.GetCategoryList)
		}
		specItemGroup := group.Group("spec")
		{
			specItemGroup.GET("/add", admin.AddItemBefore)
			specItemGroup.POST("/add", admin.AddSpec)
			specItemGroup.GET("/del", admin.DeleteSpec)
			specItemGroup.GET("/update", admin.GetItemInfo)
			specItemGroup.POST("/update", admin.UpdateSpec)
			specItemGroup.GET("/list", admin.GetSpecList)
		}

	}
	return engine
}
